class Solution(object):
    def maxSubArrayLen(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: int
        """
        prefix = {0: -1}
        n = len(nums)
        max_length = 0
        value = 0
        for i in range(n):
            value += nums[i]
            if value - k in prefix:
                max_length = max(max_length, i - prefix[value - k])
            if value not in prefix:
                prefix[value] = i
        return max_length


data = Solution()
nums = [1, -1, 5, 7, 3]
k = -3
print(data.maxSubArrayLen(nums, k))
